#include<bits/stdc++.h>

using namespace std;
int days[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

bool leap(int y) {
    if (y % 4 == 0 && y % 100 != 0 || y % 400 == 0)
        return true;
    else
        return false;
}

int getDays(int y, int m, int d) {
    int s = 0;
    for (int i = 1; i <= m - 1; i++) {
        s += days[i];
    }
    s += d;
    if (leap(y) && m > 2)
        ++s;
    return s;


}

int main() {
    int y, m, d;
    cin >> y >> m >> d;
    cout << getDays(y, m, d);

    return 0;
}